/*------------------------------------------------------
                hou_elearningGEN beta v1.0
Author: xtrung.net@gmail.com
Write On: 04/27/2008
Create On:4/13/2012 11:22:59 AM
------------------------------------------------------*/
using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

namespace hou_elearning.DataAccess
{    
    public class Hocvien_KiemtraDAL : SqlProvider<Hocvien_KiemtraEntity>
    {
        static Hocvien_KiemtraDAL()
        {
            InitReader();
        }
        protected static void InitReader()
        {
            getFromReader=delegate(SqlDataReader dr)
            {
                Hocvien_KiemtraEntity entity = new Hocvien_KiemtraEntity();
				entity.FK_iHocvienID = Int64.Parse("0"+dr["FK_iHocvienID"].ToString());
				entity.FK_iKiemtraID = Int64.Parse("0"+dr["FK_iKiemtraID"].ToString());
				entity.sMatkhau = dr["sMatkhau"].ToString();
				entity.iTrangthai = Int16.Parse("0"+dr["iTrangthai"].ToString());
                return entity;
            };
        }
        public static Hocvien_KiemtraEntity GetOne(Int64 FK_iHocvienID)
        {
            string cmdName = "spHocvien_Kiemtra_GetByPK";
            SqlParameter p = new SqlParameter("@FK_iHocvienID", FK_iHocvienID);
            Hocvien_KiemtraEntity entity = GetOne(cmdName, p);
            return entity;
        }
        public static List<Hocvien_KiemtraEntity> GetAll()
        {
            string cmdName = "spHocvien_Kiemtra_Get";
            return GetList(cmdName);
        }
        
        public static int Add(Hocvien_KiemtraEntity entity)
        {
            string cmdName = "spHocvien_Kiemtra_Insert";
            return Run(cmdName,true,initParams(entity));

        }
        public static bool Edit(Hocvien_KiemtraEntity entity)
        {
            string cmdName = "spHocvien_Kiemtra_Update";
            return Run(cmdName,false,initParams(entity))>0;
        }
        public static bool Remove(Int64 FK_iHocvienID)
        {
            string cmdName = "spHocvien_Kiemtra_Delete";
            SqlParameter p = new SqlParameter("@FK_iHocvienID", FK_iHocvienID);
            return Run(cmdName,false,p)>0;
        }
        #region private
        private static SqlParameter[] initParams(Hocvien_KiemtraEntity entity)
        {
            SqlParameter[] p = new SqlParameter[4];
			p[0] = new SqlParameter("@FK_iHocvienID", entity.FK_iHocvienID);
			p[1] = new SqlParameter("@FK_iKiemtraID", entity.FK_iKiemtraID);
			p[2] = new SqlParameter("@sMatkhau", entity.sMatkhau);
			p[3] = new SqlParameter("@iTrangthai", entity.iTrangthai);
            return p;
        }
        #endregion
       
    }
}